package com.webservice.xmloper.filterLogResult;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

import com.thoughtworks.xstream.XStream;
import com.webservice.command.utils.Constant;

public class FilterLogOper {
	
	/**
	 * 解析监测日志xml文件 
	 */
	public static FilterLogResult parseFilterLogXml(String xmlString){
		FilterLogResult filterLogResult = null;
		XStream xs = new XStream();
		xs.processAnnotations(FilterLogResult.class);
		try {
			InputStream myIn = new ByteArrayInputStream(xmlString.getBytes(Constant.CHARACTER_SET));
			filterLogResult = (FilterLogResult) xs.fromXML(myIn);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return filterLogResult;
	}

	public static String createBlockLogXml(FilterLogResult filterLogResult){
		XStream xs = new XStream();
		xs.processAnnotations(FilterLogResult.class);
		return xs.toXML(filterLogResult);
	}
	
}
